package com.rescue.mapper;

import com.rescue.forum.entity.ForumArticleAttachment;
import com.rescue.forum.entity.ForumArticleAttachmentDownload;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 附件mapper
 */
@Mapper
public interface AttachmentMapper {

    @Delete("delete from forum_article_attachment where article_id = #{articleId}")
    void deleteByArticleId(String articleId);

    void insertBatch(List<ForumArticleAttachment> list);

    @Select("select * from forum_article_attachment where file_id = #{fileId}")
    ForumArticleAttachment getById(String fileId);

    @Select("select * from forum_article_attachment_download where file_id = #{fileId} and user_id = #{userId}")
    ForumArticleAttachmentDownload getDownloadByUserIdAndFileId(String fileId, Integer userId);
}
